# Relaunch the script with administrator privileges
	If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
		Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $PSCommandArgs" -Verb RunAs
		Exit
	}

# Finding installation path (If: Uplay installation, ElseIF: Steam installation, Else: manual input)
	Write-Output "Finding installation path of MMX..."
	If ((Test-Path "HKLM:\SOFTWARE\WOW6432Node\Ubisoft\Launcher\Installs\401")) {
			Write-Output "According registry, path has been found at:"
			$key = (get-itemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Ubisoft\Launcher\Installs\401" -Name "InstallDir").InstallDir
			Write-Output $key
	} 	ElseIf ((Test-Path "HKLM:\SOFTWARE\WOW6432Node\Ubisoft\Might & Magic X Legacy")) {
			Write-Output "According registry, path has been found at:"
			$key = (get-itemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Ubisoft\Might & Magic X Legacy" -Name "GameLauncher").GameLauncher
			$key = (Split-Path -Path $key)
			Write-Output $key
	}	Else {
			$key = Read-Host "Intalation path in the reistry was not found, please enter the correct installation path of MMX: "
	}

# Checkink existence of the path
	If (Test-Path ($key)) {
			Write-Output "Path really exist, continue with installation of the MOD."
	} Else {
				Write-Output "Path does not exist, try run installation once again and enter the corect path or do installation manually."
				Exit

	}
	
# If there is not "\" at the end ft the path, then "\" is added
	If ($key[$key.Length-1] -ne "\") {
		$key = ($key+"\")
	}

# List of files stored in an array
	$listOfFiles = @(Get-Content .\list_of_files.txt)

# Is some file missing?	
	$listNotCorrupted = 1
	For($i = 0; $i -lt $listOfFiles.length; $i++) {
		$listNotCorrupted = ($listNotCorrupted -AND (Test-Path ($key+$listOfFiles[$i])))
	}

# If yes, then abort the installation
	If (!($listNotCorrupted)) {
		Write-Output "These files are missing:"	
		For($i = 0; $i -lt $listOfFiles.length; $i++) {
			If (!(Test-Path ($key+$listOfFiles[$i]))) {
				$listOfFiles[$i]
			}
		}
		$end = Read-Host "Installation ends because of some missing files. However, you can do the installation manualy. Press Enter to exit."
		Exit
	}

# Renaming of files, renamed files get extension ".modbak"
	Write-Output "Renaming of files, renamed files get extension '.modbak'..."	
	For($i = 0; $i -lt $listOfFiles.length; $i++) {
		Rename-Item ($key+$listOfFiles[$i]) ($key+$listOfFiles[$i]+".modbak")
	}

# Copying MOD files
	Write-Output "Copying MOD files..."	
	For($i = 0; $i -lt $listOfFiles.length; $i++) {
		Copy-Item (".\"+$listOfFiles[$i]) ($key+$listOfFiles[$i])
	}

$end = Read-Host "All done, press Enter to exit. Enjoy the Honorary promotion and novice teachers MOD."